package com.guagua.system.config;

import com.guagua.system.entity.UploadConfig;
import com.guagua.system.mapper.UploadConfigMapper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;

@Configuration
public class UploadStrategyConfig {
    
    @Bean
    public UploadConfig uploadConfig(UploadConfigMapper uploadConfigMapper) {
        // 从数据库获取启用的配置
        LambdaQueryWrapper<UploadConfig> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(UploadConfig::getEnabled, true);
        UploadConfig config = uploadConfigMapper.selectOne(wrapper);
        if (config == null) {
            throw new RuntimeException("未找到可用的上传配置");
        }
        return config;
    }
}